package com.example.java.base.hutool;


import cn.hutool.core.date.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import java.util.Date;

/**
 * DateUtilTest:测试时间工具类
 *
 * @author zhangxiaoxiang
 * @date 2021/01/20
 */
@Slf4j
public class DateUtilTest {
    @Test
    public void contextLoads() {
        // 2021-01-20 09:45:25
        log.info(DateUtil.now());
        // 2021-01-20
        log.info(DateUtil.today());
        //灵活的格式化时间 yyyy-MM-dd HH:mm:ss
        log.info(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
        //获取时间戳(可以获取到纳秒,false为系统时间毫秒)
        log.info(String.valueOf(DateUtil.current(false)));
        log.info(String.valueOf(DateUtil.dayOfWeekEnum(new Date())));
        log.info(String.valueOf(DateUtil.beginOfDay(new Date())));
        log.info(String.valueOf(DateUtil.endOfDay(new Date())));
        log.info(String.valueOf(DateUtil.beginOfWeek(((new Date())))));
        log.info(String.valueOf(DateUtil.offsetDay(new Date(),1)));
        log.info(String.valueOf(DateUtil.getChineseZodiac(1990)));

    }

}
